#!/bin/bash
# 统一认证凭据
AUTH="admin:123456"
PORT="8080"

echo "Testing GET /"
curl -u "$AUTH" "http://localhost:$PORT/"

echo -e "\n\nTesting POST /item1"
curl -u "$AUTH" -X POST -H "Content-Type: application/json" -d '{"foo":"bar"}' "http://localhost:$PORT/item1"

echo -e "\n\nTesting PUT /item1"
curl -u "$AUTH" -X PUT -H "Content-Type: application/json" -d '{"foo":"baz"}' "http://localhost:$PORT/item1"

echo -e "\n\nTesting DELETE /item1"
curl -u "$AUTH" -X DELETE "http://localhost:$PORT/item1"

echo -e "\n\nTesting GET /item1 (should return 404 after deletion)"
curl -u "$AUTH" "http://localhost:$PORT/item1"